package vue;
import java.awt.Color;
import javax.swing.*;
import controleur.ListeCollectionListener;
/**
 * 
 * @author Plancq Charlotte, Lanvin Kévin, Darras Raphael
 *
 *
 */
public class PanelCollections extends JPanel {
	private static final long serialVersionUID = 1L;
	private JScrollPane listeColl;
	private JList collections;
	private AffichageGlobal ag;
	
	public PanelCollections(AffichageGlobal a) {	
		this.ag=a;
		setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));

		//String[] t = {"Tintin", "Milou", "Spirou", "Les aventures de Kevin", "Martine", "Garfield","Asterix","Le Chat","Les pieds nickeles","Les geek","Martine fait des maths"};
		this.setBorder(BorderFactory.createTitledBorder("Collections"));
		collections = new JList(ag.getTraitement().getCollections());
		collections.setVisibleRowCount(3);
		collections.setBackground(new Color(214,217,223));
		collections.setName("collections");
		collections.addListSelectionListener(new ListeCollectionListener(this));
		listeColl = new JScrollPane(collections);
		listeColl.setBorder(BorderFactory.createEmptyBorder());
		//listeColl.setBorder(BorderFactory.createTitledBorder("Collections"));		
		add(listeColl);
		}

	public AffichageGlobal getAG(){
		return this.ag;
	}
	
	public JList getList(){
		return this.collections;
	}
	
	public void update(){
		collections.setListData(ag.getTraitement().getListCollections().toArray());
		collections.invalidate();collections.validate();
	}

}
